package com.fjnldx.mes.mapper.common;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fjnldx.mes.domain.pojo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
@Mapper
public interface MesContainerMapper extends BaseMapper {
    /**
     * 查询人员排班基础信息
     *
     * @param data
     * @return
     */
    List<Map<String, Object>> queryScheduling(SchedulingReq data);

    /**
     * 人员排班前纺查询
     *
     * @param data
     * @return
     */
    List<Map<String, Object>> querySchedulingQf(SchedulingReq data);

    List<Map<String, Object>> querySchedulingLt(SchedulingReq data);


    /**
     * 根据工序，开始时间，查当天生产的品种
     *
     * @param map
     * @return
     */
    List<Map<String, Object>> queryPzByGxAndNow(SchedulingReq map);

    List<Map<String, Object>> queryPzByGxAndNowQf(SchedulingReq map);
    //List<Map<String, Object>> queryPzByGxAndNowLt(SchedulingReq map);

    /**
     * 移除该人员排班
     *
     * @param data
     * @return
     */
    int deletePersonnelClasses(Scheduling data);

    /**
     * 查询昨天人员排班
     *
     * @param data
     * @return
     */
    List<Scheduling> queryScheduleYesterday(CopyBc data);

    /**
     * 插入昨天人员排班
     *
     * @param data
     * @return
     */
    int insertScheduleYesterday(CopyBc data);

    int insertScheduleYesterdayLtDs(CopyBc data);

    /**
     * 更新落纱次数-批量
     *
     * @param data
     * @return
     */
    int updateMesLscsBatch(UpdateLscsReq data);

    /**
     * 更新落纱次数-单独
     *
     * @param data
     * @return
     */
    int updateMesLscsSingle(UpdateLscsSingleReq data);

    int updateMesLscsSingleChangeDev(UpdateLscsSingleReq data);

    /**
     * 查询所有小队落纱次数单双号批量更改的机台
     *
     * @param data
     * @return
     */
    List<Map<String, Object>> queryLscsChangeBatch(InputChangeReq data);

    /**
     * 查询所有小队落纱次数单一更改的机台
     *
     * @param data
     * @return
     */
    List<Map<String, Object>> queryLscsChangeSingle(InputChangeReq data);

    /**
     * 查询各队换粗纱总锭数
     *
     * @param data
     * @return
     */
    List<Map<String, Object>> queryReplaceSumCsDs(InputChangeReq data);

    /**
     * 查询各小队换粗纱机台段数
     *
     * @param data
     * @return
     */
    List<Map<String, Object>> queryReplaceDetailCsDs(InputChangeReq data);

    /**
     * 换粗纱段数更新
     *
     * @param data
     * @return
     */
    int updateReplaceCsDs(UpdateReplaceCsDsReq data);

    int updateReplaceCsDsChangeDev(UpdateReplaceCsDsReq data);

    /**
     * 查询级联关系-集团-组织-车间-工序-工种
     */
    @Select("SELECT key_name,key_value FROM fzy_dictionary_data_list WHERE belong LIKE CONCAT('%',#{keyName},'%')")
    List<Map> queryBelong(String keyName);

    /**
     * 仅查询工人
     */
    @Select("SELECT key_name,key_value FROM fzy_dictionary_data_list WHERE belong LIKE CONCAT('%',#{keyName},'%')")
    List<Map> queryWorkersOnly(String keyName);

    /**
     * 根据id查询生产计划信息
     */
    @Select("SELECT * FROM mes_newscjh WHERE id=#{id}")
    Map<String, Object> queryProductionPlanInfo(Integer id);

    /**
     * 根据id查询生产计划信息cs
     */
    //@Select("SELECT *,IF('甲班' = #{bc}, hcsdsja, hcsdsyb) hcsds FROM mes_newscjh WHERE id=#{id}")
    Map<String, Object> queryProductionPlanInfoCs(Integer id, String bc);

    /**
     * 查询换粗纱锭数
     */
    //@Select("SELECT devSn,IF('甲班'=#{bc},hcsdsja,hcsdsyb) hcsds FROM mes_newscjh\n" +
    //        "WHERE DATEDIFF(time,#{time})=0 AND org=#{org} AND cj=#{cj} AND gongxu=#{gongxu}\n" +
    //        "AND devSn =#{devSn}")
    Map<String, Object> queryHCsDs(UpdateReplaceCsDsReq data);

    /**
     * 从钉钉表转移至人员表
     */
    int insertIntoSchedulingPersonnel(@Param("ghList") List<String> ghList);

    /**
     * 查询所有工序无对应机台工种
     */
    List<Map<String,Object>> queryNoTypeOfWorkInModel(SchedulingReq data);
    List<Map<String,Object>> queryNoTypeOfWorkInModelQf(SchedulingReq data);

}
